from selenium.webdriver.common.by import By
import time


class Mlogin:
    def login(self, driver, username, password):
        driver.find_element(By.ID, 'username').send_keys(username)
        driver.find_element(By.ID, 'password').send_keys(password)
        driver.find_element(By.ID, 'login_btn').click()
        time.sleep(1)

    def login_result(self, driver):
        result = driver.title
        return result

    def login_error_username(self, driver):
        result = driver.find_element(By.XPATH, '/html/body/div[1]/div/div/form/div[1]/span[1]').text
        return result

    def login_error_password(self, driver):
        result = driver.find_element(By.XPATH, '/html/body/div[1]/div/div/form/div[2]/span[1]').text
        return result
